﻿using System.Diagnostics;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace _01测试悬浮和弹窗01
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        //public MainWindow()
        //{
        //    InitializeComponent();
        //}

        //        private int bubbleIndex = 0;
        //        private readonly string[] bubbleTexts = new[]
        //        {
        //    "我是AI小助手安安，有什么不理解的，欢迎问我哦!",
        //    "我是 AI小助手安安，你可以尝试问我“火场内攻包含什么内容?"
        //};

        //        private void RobotImage_MouseEnter(object sender, MouseEventArgs e)
        //        {
        //            // 显示当前文本
        //            BubbleText.Text = bubbleTexts[bubbleIndex];
        //            BubblePopup.IsOpen = true;

        //        }

        //        private void RobotImage_MouseLeave(object sender, MouseEventArgs e)
        //        {
        //            BubblePopup.IsOpen = false;
        //            // 只在下次悬浮时切换
        //            bubbleIndex = (bubbleIndex + 1) % bubbleTexts.Length;
        //            Debug.WriteLine("bubbleIndex:" + bubbleIndex);
        //        }


        private int bubbleIndex = 0;
        private readonly string[] bubbleTexts = new[]
        {
    "我是AI小助手安安，有什么不理解的，欢迎问我哦!",
    "我是 AI小助手安安，你可以尝试问我“火场内攻包含什么内容?"
};

        public MainWindow()
        {
            InitializeComponent();

            // 订阅 ToolTip Opening 事件
            RobotImage.ToolTipOpening += RobotImage_ToolTipOpening;
        }

        private void RobotImage_ToolTipOpening(object sender, ToolTipEventArgs e)
        {
            
            // 切换文本
            //if (RobotToolTip.Template.FindName("ToolTipText", RobotToolTip) is TextBlock tb)
            //{
            //    tb.Text = bubbleTexts[bubbleIndex];
            //}
            ToolTipText.Text= bubbleTexts[bubbleIndex];
            bubbleIndex = (bubbleIndex + 1) % bubbleTexts.Length;
        }

        private void RobotImage_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (e.LeftButton == MouseButtonState.Pressed)
            {
                this.DragMove();
                RobotToolTip.IsOpen = false;
            }
        }
    }
}